/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation.  All Rights Reserved.
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

class Pixel
{
 protected:
  int  n[2];

 public: 
  // Constructors
  Pixel() {}

  Pixel(int x, int y)
  {
      n[0] = x;
      n[1] = y;
  }

  Pixel(double x, double y) 
  {
      n[0] = int(x);
      n[1] = int(y); 
  }

  Pixel(int d)
  { 
      n[0] = n[1] = d;
  }

  Pixel(const Pixel& v)
  {
      n[0] = v.n[0]; 
      n[1] = v.n[1]; 
  }
  //inline Pixel(const char* FileLine);  

  // Assignment operators
  Pixel& operator=(const Pixel& v) 
  {
      n[0] = v.n[0]; 
      n[1] = v.n[1]; 
      return *this; 

  }

  Pixel& operator=(const int* v)
  { n[0] = v[0]; 
  n[1] = v[1]; 
  return *this; 
  }

  Pixel& operator+=(const Pixel& v)
  {
      n[0] += v.n[0]; 
      n[1] += v.n[1]; 
      return *this; 
  }

  Pixel& operator-=(const Pixel& v)
  {
      n[0] -= v.n[0];
      n[1] -= v.n[1]; 
      return *this;
  }

  Pixel& operator*=(const int d)
  { 
      n[0] *= d; 
      n[1] *= d; 
      return *this; 
  }

  Pixel& operator/=(const int d)
  {
      n[0] /= d; 
      n[1] /= d;
      return *this;
  }

  int& operator[](int i)
  { 
      return n[i];
  }

  int operator[](int i) const 
  { 
      return n[i];
  }

  //id get(const char* FileLine);
  // geometrical trasformations
  Pixel SymFirstDiag() 
  { 
      return Pixel(n[1], n[0]);
  }

  Pixel SymAxisX() 
  { 
      return Pixel(-n[0], n[1]);
  }

  Pixel SymAxisY()
  { 
      return Pixel(n[0], -n[1]);
  }

  Pixel SymCenter()
  { 
      return Pixel(-n[0], -n[1]); 
  }

  Pixel TransXY(int x, int y)
  { 
      return Pixel(n[0] + x, n[1] + y);
  }

  Pixel TransX(int x) 
  {
      return TransXY(x, 0); 

  }
  Pixel TransY(int y)
  { 
      return TransXY(0, y); 
  }

  Pixel Rot90()
  {
      return Pixel(-n[1], n[0]);
  }

 
//  friend Pixel operator- (const Pixel& v);
Pixel operator+(const Pixel& b)
{
    Pixel c;
    c.n[0] = n[0] + b.n[0];
    c.n[1] = n[1] + b.n[1];
    return c;
}

Pixel operator-(const Pixel& b)
{
    Pixel c;
    c.n[0] = n[0] - b.n[0];
    c.n[1] = n[1] - b.n[1];
    return c;
}
}; // class Pixel

// __________________________________________________________________________


